import upload from '@/utils/upload'
import request from '@/utils/request'

// 根据票数查询作品
export function getWorksByVote(query) {
	return request({
		url: '/system/works/piaoshu',
		method: 'get',
		params: query
	})
}

// 根据发布时间查询作品
export function getWorksByTime(query) {
	return request({
		url: '/system/works/shijian',
		method: 'get',
		params: query
	})
}

// 查询作品详细
export function getWorks(worksKey) {
	return request({
		url: '/system/works/' + worksKey,
		method: 'get'
	})
}

// 发布作品
export function addWorks(data) {
	return request({
		url: '/system/works',
		method: 'post',
		data: data
	})
}

// 用户头像上传
export function uploadAvatar(data) {
	return upload({
		url: '/system/user/profile/avatar',
		name: data.name,
		filePath: data.filePath
	})
}
